package fundamentals;

public class CallByReference {

	public static void main(String[] args) {
		A a1 = new A(1);
		change(a1);
		System.out.println(a1);
	}
	
	static void change(A a) {
		a.setI(888);
	}
	
	static class A {
		
		int i;
		
		public A(int i) {
			this.i = i;
		}
		
		public void setI(int i) {
			this.i = i;
		}

		public int getI() {
			return i;
		}
		
		@Override
		public String toString() {
			return "A=" + this.i;
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + i;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			A other = (A) obj;
			if (i != other.i)
				return false;
			return true;
		}
		
		
	}
	
}
